#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'
struct Edge {
    int x, y;
} E[1000];
int ind[60], out[60];
int n, m = 0;
vector<int> v;

bool topsort() {
    int cnt = 0;
    queue<int> Q;
    for (int i = 0; i < n; i++) {
        if (ind[i] == 0) {
            Q.push(i);
        }
    }
    cerr << Q.size() << endl;
    while (!Q.empty()) {
        int temp = Q.front();//如果是优先队列，这里可以是top()
        v.push_back(temp);
        Q.pop();
        ++cnt;
        for (auto e:E) {
            if (e.x == temp) {
                ind[e.y]--;
                if (ind[e.y] == 0) {
                    Q.push(e.y);
                }
            }
        }
    }
    return cnt == n;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) {
            int t;
            cin >> t;
            if (t != 0) {
                E[m++] = {i, j};
                ind[j]++;
            }
        }
    if (topsort()) {
        copy(v.begin(), v.end(), ostream_iterator<int>(cout, " "));
        cout << endl;
    } else {
        cout << "ERROR" << endl;
    }
    return 0;
}
